﻿<%@ Page Language="C#" MasterPageFile="~/car-insurance/UserLogin.master" AutoEventWireup="true"
    CodeFile="login.aspx.cs" Inherits="car_insurance_login" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <script src="../includes/ValidationError-NEW.js" type="text/javascript"></script>

    <script src="../includes/ValidationEffect-NEW.js" type="text/javascript"></script>

    <script src="../controls/IdNumber.js" type="text/javascript"></script>

    <script src="../includes/LoadingProgress.js" type="text/javascript"></script>

    <script type="text/javascript">
        // Load the SDK Asynchronously
        (function(d) {
            var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
            if (d.getElementById(id)) { return; }
            js = d.createElement('script'); js.id = id; js.async = true;
            js.src = "//connect.facebook.net/en_US/all.js";
            ref.parentNode.insertBefore(js, ref);
        } (document));

        // Init the SDK upon load
        window.fbAsyncInit = function() {
            FB.init({
                appId: '386810108100484', // App ID
                channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File
                status: true, // check login status
                cookie: true, // enable cookies to allow the server to access the session
                xfbml: true  // parse XFBML
            });
        }

        function userLogin() {
            FB.login(function(response) {
                if (response.authResponse) {
                    // user has auth'd your app and is logged into Facebook
                    var access_token = response.authResponse.accessToken;
                    FB.api('/me?fields=email,first_name,last_name,gender,birthday,relationship_status', function(me) {
                        if (me.name) {
                            document.getElementById('auth-displayname').innerHTML = me.name;
                        }
                        //document.getElementById('auth-email').innerHTML = me.id + ", " + me.email + ", " + me.name + ", " + me.first_name + ", " + me.last_name + ", " + me.link + ", " + me.username + ", " + me.gender + ", " + me.locale + ", " + me.age_range.min + ", " + me.birthday + ", " + me.picture.data.url + ", " + me.currency.user_currency;
                        document.getElementById('<%= hiddenData.ClientID %>').value = me.email + ";" + me.first_name + ";" + me.last_name + ";" + me.gender + ";" + me.birthday + ";" + me.relationship_status;
                        if (me.email != "undefined" && me.email != "") {
                            var clickButton = document.getElementById("<%= btnFBLogin.ClientID %>");
                            clickButton.click();
                        }
                    })
                } else {
                    // user has not auth'd your app, or is not logged into Facebook
                }
            }, { scope: 'email,user_birthday,user_relationships' });
        }  
    </script>

    <div id="contentBody_login">
        <div class="seperator">
        </div>
        <div class="formouter">
            <div class="section_new">
                <h1>
                    Sign in</h1>
                <!-- Member Area [[ NOT LOGGED IN ]]  |  Start  -->
                <fieldset>
                    <div class="login" id="divLogin" runat="server">
                        <div>
                            <asp:ValidationSummary ID="vsExCustomer" HeaderText="Oops please complete the form"
                                runat="server" ValidationGroup="excustomer" ShowSummary="True" CssClass="err_padding">
                            </asp:ValidationSummary>
                            <div class="errorSummary" id="divExErrorMessage" runat="server" visible="false">
                                <asp:Label ID="lblLoginMessage" runat="server"></asp:Label>
                                <asp:Label runat="server" ID="lblRED" Visible="false" />
                            </div>
                        </div>
                        <div class="row_curved">
                            <label class="mand_red">
                                Email Address:</label>
                            <div class="field">
                                <span class="indicator">
                                    <asp:TextBox ID="txtExEmail" runat="server" MaxLength="80" Width="210px" />
                                    <asp:RequiredFieldValidator ID="rfvExEmail" CssClass="validationErrorControl" runat="server"
                                        ValidationGroup="excustomer" ErrorMessage="" Text="" ControlToValidate="txtExEmail"
                                        Display="Dynamic"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator CssClass="validationErrorControl" ID="rfvExEmailValid"
                                        runat="server" ValidationGroup="excustomer" ErrorMessage="" Text="" ControlToValidate="txtExEmail"
                                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
                                </span>
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="row_curved">
                            <label class="mand_red">
                                Password:</label>
                            <div class="field">
                                <span class="indicator">
                                    <asp:TextBox ID="txtExAuthCode" MaxLength="20" runat="server" TextMode="Password"
                                        Width="210px" /><%--onfocus="this.value='';" --%>
                                    <asp:RequiredFieldValidator ID="rfvExAuthCode" CssClass="validationErrorControl"
                                        runat="server" ValidationGroup="excustomer" ErrorMessage="" Text="" ControlToValidate="txtExAuthCode"
                                        Display="Dynamic"></asp:RequiredFieldValidator>
                                </span>
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="formButtons_new1">
                            <div class="nextstep">
                                <span class="button2">
                                    <%--<asp:ImageButton ValidationGroup="excustomer" ID="ibtLogin" OnClientClick="LoadValidationErrorCss();"
                                        ImageUrl="~/images/button/login.gif" AlternateText="Login" Style="vertical-align: bottom;
                                        margin-left: 7px;" runat="server" OnClick="ibtLogin_Click" />--%>
                                    <asp:Button runat="server" ID="btnLogin" ValidationGroup="excustomer" CssClass="button_login_m"
                                        OnClientClick="LoadValidationErrorCss();if (Page_ClientValidate('excustomer')) { this.removeAttribute('onmouseout'); this.removeAttribute('onmouseup'); this.className = 'button_m_processing';}"
                                        onmousedown="this.className = 'button_login_m_mousedown';" onmouseup="this.className = 'button_login_m';"
                                        onmouseout="this.className = 'button_login_m';" OnClick="btnLogin_Click" />
                                </span>
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="row_noc">
                            <div id="auth-status" style="display:none;">
                                <a href="#" onclick="userLogin()">
                                    <div style="display: inline-block; background-color: #5f78ab; color: #fff; cursor: pointer;
                                        vertical-align: top; font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
                                        font-size: 11px;">
                                        <table style="border: 0; border-collapse: collapse; border-spacing: 0;" cellspacing="0"
                                            cellpadding="0">
                                            <tbody>
                                                <tr>
                                                    <td style="text-align: left;">
                                                        <i style="width: 22px; height: 22px; background-position: 0 -132px; background-image: url(http://static.ak.fbcdn.net/rsrc.php/v2/yx/r/j_i0CTUUUEe.png);
                                                            background-size: auto; background-repeat: no-repeat; display: inline-block;">
                                                        </i><i style="display: none;"></i><span style="display: none; border-right: 1px solid #405b91;
                                                            border-top: 1px solid #29447e; border-left: 1px solid #29447e; border-bottom: 1px solid #1a356e;">
                                                            <i style="border-top: 1px solid #879ac0; vertical-align: top; background-image: url(http://static.ak.fbcdn.net/rsrc.php/v2/yx/r/j_i0CTUUUEe.png);
                                                                background-size: auto; background-repeat: no-repeat; display: inline-block; height: 39px;
                                                                width: 39px;"></i></span>
                                                    </td>
                                                    <td style="text-align: left;">
                                                        <span style="display: inline-block; border-top: 1px solid #29447e; border-right: 1px solid #29447e;
                                                            border-bottom: 1px solid #1a356e;"><span style="font-size: 11px; line-height: 14px;
                                                                padding: 2px 6px 3px; font-weight: bold; display: inline-block; border-top: 1px solid #879ac0;
                                                                white-space: nowrap;">Login with Facebook</span></span>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </a>
                            </div>
                            <asp:HiddenField ID="hiddenData" runat="server" />
                            <div style="display:none;">
                            <asp:Button ID="btnFBLogin" runat="server" Text="Click me!" OnClick="btnFBLogin_Click"
                                Style="display: none;" />
                                </div>
                            <label>
                            </label>
                            <div class="field">
                                <span class="indicator">
                                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/user/passwordrecovery.aspx">Forgotten your password?</asp:HyperLink>
                                </span>
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <!-- Member Area [[ NOT LOGGED IN ]]  |  End  -->
                </fieldset>
            </div>
            <div class="wrap_login">
                <div class="login_info">
                    <h3>
                        Your account</h3>
                    <p>
                        With your CompareXpress account you can:</p>
                    <ul>
                        <li>Retrieve saved insurance quotes</li>
                        <li>Re-run quotes without filling out all the required fields</li>
                        <li>Edit your contact preferences and update your details</li>
                    </ul>
                    <h3>
                        Trouble logging in?</h3>
                    If you've forgotten your password, <a href="/user/passwordrecovery.aspx">follow this
                        link to reset it</a>
                    <div class="seperator">
                    </div>
                    <h3>
                        New to CompareXpress?</h3>
                    Compare <a href="/car-insurance/">car insurance quote here</a><br />
                    Compare <a href="/personal-accident/">personal accident insurance quote here</a><br />
                    Compare <a href="/travel-flights/">air fares here</a><br />
                    Compare <a href="/travel-insurance/">travel insurance quote here</a>
                </div>
            </div>
            <div class="clear">
            </div>
        </div>
    </div>
</asp:Content>
